package com.sikulifang.bank.simulation.util;

import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.InputStream;
import java.util.HashMap;
import java.util.Map;

public class FileCache {

    private static final FileCache INSTANCE = new FileCache();
    private final Map<String, byte[]> cache;

    private FileCache() {
        cache = new HashMap<>();
        String filePath = "pdf";
        File file = new File("pdf/template.pdf");
        byte[] bytesByFile = PdfUtil.getBytesByFile(file.getPath());
        cache.put(filePath, bytesByFile);
    }

    public static FileCache getInstance() {
        return INSTANCE;
    }

    public InputStream getInputStream() {
        String filePath = "pdf";
        return new ByteArrayInputStream(cache.get(filePath));
    }
}